#ifndef TCPSERVER_H
#define TCPSERVER_H

#include <sys/socket.h>
#include <sys/epoll.h>
#include <unistd.h>
#include <iostream>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unordered_map>
#include <functional>

#include "EventLoop.hpp"
#include "Buffer.hpp"

class TcpServer {
public:
    TcpServer();
    ~TcpServer();

    
    void start(unsigned short port); 
    inline void setMessageCallBack(CallBackPtr callbackptr){
        userMessageCall_ = callbackptr;
    }

    inline void setConnectionCallBack(CallBackPtr callbackptr) {
        userConnectionCall_ = callbackptr;
    }

    

private:
    int listenFd_;
    EventLoop eventLoop_;

    int setListen(unsigned short port);
    void connectionCallBack(ConnectionPtr conn); // 传入tcpconnection
    void messageCallBack(ConnectionPtr conn);
    CallBackPtr userMessageCall_;
    CallBackPtr userConnectionCall_;
    
};






#endif